/*
               File: GXLRI28
        Description: Load referential integrity
             Author: GeneXus Java Generator version 8_0_9-040
       Generated on: 28 de Setiembre de 2010 14:36:59.27
       Program type: Callable routine
          Main DBMS: sqlserver
*/
import java.sql.*;
import com.genexus.db.*;
import com.genexus.*;
import com.genexus.distributed.*;

public final class gxlri28 extends GXProcedure
{
   public gxlri28( int remoteHandle )
   {
      super( remoteHandle , new ModelContext( gxlri28.class ), "" );
   }

   public gxlri28( int remoteHandle ,
                   ModelContext context )
   {
      super( remoteHandle , context, "" );
   }

   public void execute( )
   {
      execute_int();
   }

   private void execute_int( )
   {
      initialize();
      /* GeneXus formulas */
      /* Output device settings */
      /* Using cursor GXLRI282 */
      pr_default.execute(0);
      while ( (pr_default.getStatus(0) != 101) )
      {
         A385ModCod = GXLRI282_A385ModCod[0] ;
         A35PrsCod = GXLRI282_A35PrsCod[0] ;
         A445CliCod = GXLRI282_A445CliCod[0] ;
         A417PrsVeh = GXLRI282_A417PrsVeh[0] ;
         /*
            INSERT RECORD ON TABLE MMMDA10

         */
         W189MarCod = A189MarCod ;
         W189MarCod = A189MarCod ;
         W385ModCod = A385ModCod ;
         W385ModCod = A385ModCod ;
         W386ModNom = A386ModNom ;
         W386ModNom = A386ModNom ;
         W387ModFCR = A387ModFCR ;
         W387ModFCR = A387ModFCR ;
         W388ModHCR = A388ModHCR ;
         W388ModHCR = A388ModHCR ;
         W389ModUCR = A389ModUCR ;
         W389ModUCR = A389ModUCR ;
         W390ModFUM = A390ModFUM ;
         W390ModFUM = A390ModFUM ;
         W391ModHUM = A391ModHUM ;
         W391ModHUM = A391ModHUM ;
         W392ModUUM = A392ModUUM ;
         W392ModUUM = A392ModUUM ;
         W592ModEst = A592ModEst ;
         W592ModEst = A592ModEst ;
         if ( ((GXutil.strcmp("", GXutil.rtrim( A189MarCod))==0)) )
         {
            A189MarCod = " " ;
         }
         else
         {
         }
         if ( GXLRI282_n385ModCod[0] )
         {
            A385ModCod = " " ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A386ModNom))==0)) )
         {
            A386ModNom = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A387ModFCR)) )
         {
            A387ModFCR = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A388ModHCR))==0)) )
         {
            A388ModHCR = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A389ModUCR))==0)) )
         {
            A389ModUCR = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A390ModFUM)) )
         {
            A390ModFUM = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A391ModHUM))==0)) )
         {
            A391ModHUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A392ModUUM))==0)) )
         {
            A392ModUUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A592ModEst))==0)) )
         {
            A592ModEst = "" ;
         }
         else
         {
         }
         /* Using cursor GXLRI283 */
         pr_default.execute(1, new Object[] {A189MarCod, A385ModCod, A386ModNom, A387ModFCR, A388ModHCR, A389ModUCR, A390ModFUM, A391ModHUM, A392ModUUM, A592ModEst});
         if ( (pr_default.getStatus(1) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         A189MarCod = W189MarCod ;
         A189MarCod = W189MarCod ;
         A385ModCod = W385ModCod ;
         A385ModCod = W385ModCod ;
         A386ModNom = W386ModNom ;
         A386ModNom = W386ModNom ;
         A387ModFCR = W387ModFCR ;
         A387ModFCR = W387ModFCR ;
         A388ModHCR = W388ModHCR ;
         A388ModHCR = W388ModHCR ;
         A389ModUCR = W389ModUCR ;
         A389ModUCR = W389ModUCR ;
         A390ModFUM = W390ModFUM ;
         A390ModFUM = W390ModFUM ;
         A391ModHUM = W391ModHUM ;
         A391ModHUM = W391ModHUM ;
         A392ModUUM = W392ModUUM ;
         A392ModUUM = W392ModUUM ;
         A592ModEst = W592ModEst ;
         A592ModEst = W592ModEst ;
         /* End Insert */
         /* Check if program is canceled. */
         pr_default.readNext(0);
      }
      pr_default.close(0);
      /* Using cursor GXLRI284 */
      pr_default.execute(2);
      while ( (pr_default.getStatus(2) != 101) )
      {
         A385ModCod = GXLRI284_A385ModCod[0] ;
         A519MVehCo = GXLRI284_A519MVehCo[0] ;
         /*
            INSERT RECORD ON TABLE MMMDA10

         */
         W189MarCod = A189MarCod ;
         W189MarCod = A189MarCod ;
         W385ModCod = A385ModCod ;
         W385ModCod = A385ModCod ;
         W386ModNom = A386ModNom ;
         W386ModNom = A386ModNom ;
         W387ModFCR = A387ModFCR ;
         W387ModFCR = A387ModFCR ;
         W388ModHCR = A388ModHCR ;
         W388ModHCR = A388ModHCR ;
         W389ModUCR = A389ModUCR ;
         W389ModUCR = A389ModUCR ;
         W390ModFUM = A390ModFUM ;
         W390ModFUM = A390ModFUM ;
         W391ModHUM = A391ModHUM ;
         W391ModHUM = A391ModHUM ;
         W392ModUUM = A392ModUUM ;
         W392ModUUM = A392ModUUM ;
         W592ModEst = A592ModEst ;
         W592ModEst = A592ModEst ;
         if ( ((GXutil.strcmp("", GXutil.rtrim( A189MarCod))==0)) )
         {
            A189MarCod = " " ;
         }
         else
         {
         }
         if ( GXLRI284_n385ModCod[0] )
         {
            A385ModCod = " " ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A386ModNom))==0)) )
         {
            A386ModNom = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A387ModFCR)) )
         {
            A387ModFCR = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A388ModHCR))==0)) )
         {
            A388ModHCR = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A389ModUCR))==0)) )
         {
            A389ModUCR = "" ;
         }
         else
         {
         }
         if ( (GXutil.nullDate().equals(A390ModFUM)) )
         {
            A390ModFUM = GXutil.nullDate() ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A391ModHUM))==0)) )
         {
            A391ModHUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A392ModUUM))==0)) )
         {
            A392ModUUM = "" ;
         }
         else
         {
         }
         if ( ((GXutil.strcmp("", GXutil.rtrim( A592ModEst))==0)) )
         {
            A592ModEst = "" ;
         }
         else
         {
         }
         /* Using cursor GXLRI285 */
         pr_default.execute(3, new Object[] {A189MarCod, A385ModCod, A386ModNom, A387ModFCR, A388ModHCR, A389ModUCR, A390ModFUM, A391ModHUM, A392ModUUM, A592ModEst});
         if ( (pr_default.getStatus(3) == 1) )
         {
            Gx_err = (short)(1) ;
            Gx_emsg = localUtil.getMessages().getMessage("noupdate") ;
         }
         else
         {
            Gx_err = 0 ;
            Gx_emsg = "" ;
         }
         A189MarCod = W189MarCod ;
         A189MarCod = W189MarCod ;
         A385ModCod = W385ModCod ;
         A385ModCod = W385ModCod ;
         A386ModNom = W386ModNom ;
         A386ModNom = W386ModNom ;
         A387ModFCR = W387ModFCR ;
         A387ModFCR = W387ModFCR ;
         A388ModHCR = W388ModHCR ;
         A388ModHCR = W388ModHCR ;
         A389ModUCR = W389ModUCR ;
         A389ModUCR = W389ModUCR ;
         A390ModFUM = W390ModFUM ;
         A390ModFUM = W390ModFUM ;
         A391ModHUM = W391ModHUM ;
         A391ModHUM = W391ModHUM ;
         A392ModUUM = W392ModUUM ;
         A392ModUUM = W392ModUUM ;
         A592ModEst = W592ModEst ;
         A592ModEst = W592ModEst ;
         /* End Insert */
         /* Check if program is canceled. */
         pr_default.readNext(2);
      }
      pr_default.close(2);
      cleanup();
   }

   protected void cleanup( )
   {
      exitApplication();
   }

   /* Aggregate/select formulas */
   public void initialize( )
   {
      GXLRI282_A385ModCod = new String[] {""} ;
      GXLRI282_A35PrsCod = new String[] {""} ;
      GXLRI282_A445CliCod = new short[1] ;
      GXLRI282_A417PrsVeh = new short[1] ;
      A385ModCod = "" ;
      A35PrsCod = "" ;
      A445CliCod = 0 ;
      A417PrsVeh = 0 ;
      GX_INS28 = 0 ;
      W189MarCod = "" ;
      A189MarCod = "" ;
      W385ModCod = "" ;
      W386ModNom = "" ;
      A386ModNom = "" ;
      W387ModFCR = GXutil.nullDate() ;
      A387ModFCR = GXutil.nullDate() ;
      W388ModHCR = "" ;
      A388ModHCR = "" ;
      W389ModUCR = "" ;
      A389ModUCR = "" ;
      W390ModFUM = GXutil.nullDate() ;
      A390ModFUM = GXutil.nullDate() ;
      W391ModHUM = "" ;
      A391ModHUM = "" ;
      W392ModUUM = "" ;
      A392ModUUM = "" ;
      W592ModEst = "" ;
      A592ModEst = "" ;
      GXLRI282_n385ModCod = new boolean[] {false} ;
      Gx_err = 0 ;
      Gx_emsg = "" ;
      GXLRI284_A385ModCod = new String[] {""} ;
      GXLRI284_A519MVehCo = new short[1] ;
      A519MVehCo = 0 ;
      GXLRI284_n385ModCod = new boolean[] {false} ;
      pr_default = new DataStoreProvider(context, remoteHandle, new gxlri28__default(),
         new Object[] {
             new Object[] {
            GXLRI282_A385ModCod, GXLRI282_n385ModCod, GXLRI282_A35PrsCod, GXLRI282_A445CliCod, GXLRI282_A417PrsVeh
            }
            , new Object[] {
            }
            , new Object[] {
            GXLRI284_A385ModCod, GXLRI284_n385ModCod, GXLRI284_A519MVehCo
            }
            , new Object[] {
            }
         }
      );
      /* GeneXus formulas. */
      Gx_err = 0 ;
   }

   private short A445CliCod ;
   private short A417PrsVeh ;
   private short Gx_err ;
   private short A519MVehCo ;
   private int GX_INS28 ;
   private String A385ModCod ;
   private String A35PrsCod ;
   private String W189MarCod ;
   private String A189MarCod ;
   private String W385ModCod ;
   private String W386ModNom ;
   private String A386ModNom ;
   private String W388ModHCR ;
   private String A388ModHCR ;
   private String W389ModUCR ;
   private String A389ModUCR ;
   private String W391ModHUM ;
   private String A391ModHUM ;
   private String W392ModUUM ;
   private String A392ModUUM ;
   private String W592ModEst ;
   private String A592ModEst ;
   private String Gx_emsg ;
   private java.util.Date W387ModFCR ;
   private java.util.Date A387ModFCR ;
   private java.util.Date W390ModFUM ;
   private java.util.Date A390ModFUM ;
   private IDataStoreProvider pr_default ;
   private String[] GXLRI282_A385ModCod ;
   private String[] GXLRI282_A35PrsCod ;
   private short[] GXLRI282_A445CliCod ;
   private short[] GXLRI282_A417PrsVeh ;
   private boolean[] GXLRI282_n385ModCod ;
   private String[] GXLRI284_A385ModCod ;
   private short[] GXLRI284_A519MVehCo ;
   private boolean[] GXLRI284_n385ModCod ;
}

final class gxlri28__default extends DataStoreHelperBase implements ILocalDataStoreHelper
{
   public Cursor[] getCursors( )
   {
      return new Cursor[] {
          new ForEachCursor("GXLRI282", "SELECT [ModCod], [PrsCod], [CliCod], [PrsVehCod] FROM [MMCLI30] WITH (NOLOCK) ORDER BY [PrsCod], [CliCod], [PrsVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("GXLRI283", "INSERT INTO [MMMDA10] ([MarCod], [ModCod], [ModNom], [ModFCR], [ModHCR], [ModUCR], [ModFUM], [ModHUM], [ModUUM], [ModEst]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
         ,new ForEachCursor("GXLRI284", "SELECT [ModCod], [MVehCod] FROM [MMVEH10] WITH (NOLOCK) ORDER BY [MVehCod] ",false, GX_NOMASK + GX_MASKLOOPLOCK, false, this,0,false )
         ,new UpdateCursor("GXLRI285", "INSERT INTO [MMMDA10] ([MarCod], [ModCod], [ModNom], [ModFCR], [ModHCR], [ModUCR], [ModFUM], [ModHUM], [ModUUM], [ModEst]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", GX_NOMASK + GX_MASKLOOPLOCK)
      };
   }

   public void getResults( int cursor ,
                           IFieldGetter rslt ,
                           Object[] buf ) throws SQLException
   {
      switch ( cursor )
      {
            case 0 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((String[]) buf[2])[0] = rslt.getString(2, 10) ;
               ((short[]) buf[3])[0] = rslt.getShort(3) ;
               ((short[]) buf[4])[0] = rslt.getShort(4) ;
               break;
            case 2 :
               ((String[]) buf[0])[0] = rslt.getString(1, 10) ;
               ((boolean[]) buf[1])[0] = rslt.wasNull();
               ((short[]) buf[2])[0] = rslt.getShort(2) ;
               break;
      }
   }

   public void setParameters( int cursor ,
                              IFieldSetter stmt ,
                              Object[] parms ) throws SQLException
   {
      switch ( cursor )
      {
            case 1 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 10);
               stmt.setString(3, (String)parms[2], 50);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setString(6, (String)parms[5], 10);
               stmt.setDate(7, (java.util.Date)parms[6]);
               stmt.setString(8, (String)parms[7], 8);
               stmt.setString(9, (String)parms[8], 10);
               stmt.setString(10, (String)parms[9], 1);
               break;
            case 3 :
               stmt.setString(1, (String)parms[0], 10);
               stmt.setString(2, (String)parms[1], 10);
               stmt.setString(3, (String)parms[2], 50);
               stmt.setDate(4, (java.util.Date)parms[3]);
               stmt.setString(5, (String)parms[4], 8);
               stmt.setString(6, (String)parms[5], 10);
               stmt.setDate(7, (java.util.Date)parms[6]);
               stmt.setString(8, (String)parms[7], 8);
               stmt.setString(9, (String)parms[8], 10);
               stmt.setString(10, (String)parms[9], 1);
               break;
      }
   }

}

